from rest_framework import serializers


class NewsCreateSerializer(serializers.Serializer):
    title = serializers.CharField()
    subtitle = serializers.CharField(required=False, allow_null=True)
    content = serializers.CharField()
    content_div = serializers.CharField(required=False, allow_null=True)
    category = serializers.CharField()
    status = serializers.IntegerField(required=False, default=1)
    image_list = serializers.CharField(required=False, allow_null=True)
    video_list = serializers.CharField(required=False, allow_null=True)
    audio_list = serializers.CharField(required=False, allow_null=True)
    editor = serializers.CharField(required=False, allow_null=True)
    link = serializers.CharField(required=False, allow_null=True)
    source = serializers.CharField(required=False, allow_null=True)
    release_date = serializers.DateTimeField(required=False, allow_null=True)
    origin_id = serializers.IntegerField(required=False, allow_null=True)


class NewsDetailSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField()
    subtitle = serializers.CharField(allow_null=True)
    content = serializers.CharField()
    content_div = serializers.CharField(allow_null=True)
    category = serializers.CharField()
    status = serializers.IntegerField()
    created_at = serializers.DateTimeField()
    updated_at = serializers.DateTimeField()
    image_list = serializers.CharField(allow_null=True)
    video_list = serializers.CharField(allow_null=True)
    audio_list = serializers.CharField(allow_null=True)
    editor = serializers.CharField(allow_null=True)
    link = serializers.CharField(allow_null=True)
    source = serializers.CharField(allow_null=True)
    release_date = serializers.DateTimeField(allow_null=True)
    origin_id = serializers.IntegerField(allow_null=True)


class NewsUpdateSerializer(serializers.Serializer):
    title = serializers.CharField(required=False)
    subtitle = serializers.CharField(required=False, allow_null=True)
    content = serializers.CharField(required=False)
    content_div = serializers.CharField(required=False, allow_null=True)
    category = serializers.CharField(required=False)
    status = serializers.IntegerField(required=False)
    image_list = serializers.CharField(required=False, allow_null=True)
    video_list = serializers.CharField(required=False, allow_null=True)
    audio_list = serializers.CharField(required=False, allow_null=True)
    editor = serializers.CharField(required=False, allow_null=True)
    link = serializers.CharField(required=False, allow_null=True)
    source = serializers.CharField(required=False, allow_null=True)
    release_date = serializers.DateTimeField(required=False, allow_null=True)
    origin_id = serializers.IntegerField(required=False, allow_null=True)


class NewsListSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    title = serializers.CharField()
    subtitle = serializers.CharField(allow_null=True)
    category = serializers.CharField()
    status = serializers.IntegerField()
    created_at = serializers.DateTimeField()
    editor = serializers.CharField(allow_null=True)
    source = serializers.CharField(allow_null=True)


class NewsDeleteSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    confirm = serializers.BooleanField(
        required=True,
        help_text="必须设置为true才能执行删除操作"
    )